package org.pentaho.di.ui.util;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.pentaho.di.i18n.BaseMessages;

/**
* @ClassName: SWTMessageUtil
* @Description: TODO
* @author zhangbinp
* @date Nov 3, 2011 9:31:51 AM
*/
public class SWTMessageUtil {
	public static void alert(Shell shell,String message,String text){
		MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_WARNING );
		mb.setMessage(message);
		mb.setText(text);
		mb.open(); 
	}
	public static void confirm(Shell shell,String message, String text,CallBack callBack){
		MessageBox mb = new MessageBox(shell,SWT.ICON_WARNING | SWT.YES | SWT.NO);
		mb.setMessage(message);
		mb.setText(text);
		int choice = mb.open();
		if(choice == SWT.YES){
			callBack.doYes();
		} else if(choice == SWT.NO){
			callBack.doNo();
		}
	}
	public interface CallBack{
		public void doYes();
		public void doNo();
	}
	public static void main(String[] args) {
		SWTMessageUtil.confirm(new Shell(),"Are U sure?","Tip",new CallBack(){
			public void doYes(){
				System.err.println("yes");
			}
			public void doNo(){
				System.err.println("no");		
		}
		});
	}
}


